In [1]:
#Pkg.add("SymPy") # Run this line the first time to install the SymPy package
using SymPy
In [2]:
@syms x, q, R1, R2, l, i, E
M1(x) = R1*x-(q*x^(2))/(2)
M2(x) = R1*x+R2*(x-l/(2))-(q*x^(2))/(2)
Out[2]:
Using Castigliano's second theorem, that states $$\frac{\partial U}{\partial Q_i}=q_i$$
Where $Q_i$ is genneralized forces and $q_i$ is genneralized displacements. Since there is no deflection in the two supports then the differentiated with repect to the reaction force set to zero
In [3]:
U = integrate(M1(x)^2/(2*E*i),x,0,l/2) + integrate(M2(x)^2/(2*E*i),x,l/2,l)
Out[3]:
In [4]:
eq1 = diff(U,R1)
Out[4]:
In [5]:
eq2= diff(U,R2)
Out[5]:
In [6]:
solve([eq1,eq2], [R1, R2])
Out[6]:
Super, return the same as maple
Since we would like to find the displacement in point A, we call it P1 and then later apply the relation between P and P1
In [7]:
@syms x, q, P, P1, l, i, E
M1(x) = ((l-x)*2)*P
M2(x) = ((l-x)*2)*P-P1*((1/2)*l-x)
U = integrate(M2(x)^2/(2*E*i),x,0,l/2) + integrate(M1(x)^2/(2*E*i),x,l/2,l)
Out[7]:
differentiating with respect to P1
In [8]:
eq1 = diff(U, P1)
Out[8]:
Remember that P1 is equal P and substitue in the equation. So the displacement in point A isequal to
In [9]:
eq1(P1 => P) # Substitute P1 with P
Out[9]:
In [10]:
M1(x) = x*P
M2(x) = x*P-(x-l/(2))*3/(2)*P
U = integrate(M1(x)^2/(2*E*i),x,0,l/2) + integrate(M2(x)^2/(2*E*i), x, l/2, l*3/2)
eq1 = diff(U, P)
Out[10]:
Displacement in point P is found
In [11]:
M1(x) = x*P+(q*x^(2))/(2)
Out[11]:
In [12]:
U = integrate(M1(x)^2/(2*E*i),x,0,l)
eq1 = diff(U, P)
Out[12]:
Rember that P is equal 0, the displacement in x=0 is
In [13]:
eq1(P=>0)
Out[13]:
In [14]:
@syms M
M1(x) = M+(q*x^(2))/(2)
M2(x) = M+(q*l^(2))/(2)
U = integrate(M1(x)^2/(2*E*i),x,0,l) + integrate(M2(x)^2/(2*E*i),x,l,2l)
eq1 = diff(U, M)
# M is 0
eq1(M=>0)
Out[14]:
In [15]:
@syms q1,q2, A, Q1, E_mod
θ = 30*((1/180)*pi)
ɛ1(x) = q1/l
ɛ2(x) = 2*q2/l
ɛ3(x) = (cos((1/4)*pi)*q1+cos((1/4)*pi)*q2)/l
U = integrate((E_mod*A*ɛ1(x)^2)/2,x,0,l) + integrate((E_mod*A*ɛ2(x)^2)/2,x,0,l/2) + integrate((E_mod*A*ɛ3(x)^2)/2,x,0,l) - Q1*q1*cos(θ)-Q1*q2*sin(θ)
eq2 = diff(U,q2)
eq1 = diff(U,q1)
solve([eq1, eq2], [q1, q2])
Out[15]:
In [16]:
@syms R1
M1(x) = P1*x
M2(x) = P1*l+R1*x
M3(x) = P1*l+R1*x-2*P*(x-l)
M4(x) = P1*(l-x)+R1*l*(3)/(2)-2*P*(l)/(2)
U = integrate(M1(x)^2/(2*E*i),x,0,l) + integrate(M2(x)^2/(2*E*i),x,0,l) +
integrate(M3(x)^2/(2*E*i),x,l,3*l/2) + integrate(M4(x)^2/(2*E*i),x,0,l/2)
eq1 = diff(U,P1)(P1 => P)
eq2 = diff(U,R1)(P1 => P)
r1 = solve(eq2, R1)[1]
Out[16]:
In [17]:
δ_p = eq1(R1=>r1)
Out[17]:
In [18]:
@syms Mb, R1,R2
M1(x) = P*x
M2(x) = P*x-R1*(x-l/(2))+Mb
M3(x) = P*x-R1*(x-l/(2))-R2*(x-(3* l)/(2))+Mb
U = integrate(M1(x)^2/(2*E*i),x,0,l/2) + integrate(M2(x)^2/(2*E*i),x,l/2,l*3/2) +
integrate(M3(x)^2/(2*E*i),x,3/2 * l,5*l/2)
#Reaction forces is determined from eq1 and eq2
eq1 = subs(diff(U,R1),Mb, 0)
eq2 = subs(diff(U,R2),Mb, 0)
res = solve([eq1, eq2], [R1, R2])
Out[18]:
In [19]:
eq3 = diff(U,P)(Mb => 0 ,res...)
Out[19]:
In [20]:
eq4 = diff(U,Mb)(Mb => 0 ,res...)
Out[20]:
In [ ]: